<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,initial-scale=1.0,width=device-width" />
    <meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
    <title>我的应聘</title>
    <link rel="stylesheet" type="text/css" href="../../../css/aui/aui.css" />
    <link rel="stylesheet" type="text/css" href="../../../css/html/order/get_work_frm.css" />
    <link rel="stylesheet" type="text/css" href="../../../css/html/my/myapply/myapply.css" />
    <style>

    </style>
</head>

<body>
    <div id="app" v-clock>
        <div class="tab_nav">
            <div class="aui-tab border_b" id="tab">
                <div class="aui-tab-item aui-active">专业用工类</div>
                <div class="aui-tab-item">零活类</div>
            </div>
        </div>
        <div class="tab-content" style="margin-top:2.5rem">
            <div v-for="o,i in list" style="border-bottom:1px solid #eeeeee;margin-bottom:1rem;">
                <div class="aui-list" @click="openDemandDetails({id:o.work_id,isMobile:o.apply_status===2})">
                    <div class="aui-list-item">
                        <div class="aui-list-item-inner">
                            <div class="aui-list-itemrem;-title aui-ellipsis-1">{{o.title}}</div>
                        </div>
                    </div>
                    <div class="aui-list-item">
                        <div class="aui-media-list-item-inner">
                            <div class="aui-list-item-media">
                                <img :src="o.headimgurl" onerror='this.src="../../../image/portrait.png"' style="border-radius:50%;overflow:hidden;border:1px solid #eee;">
                            </div>
                            <div class="person_info">
                                <div> <img src="../../../image/icon/menu02-1.png" class="iconimg" alt=""> <span>联系人：{{o.contact}}</span></div>
                                <div> <img src="../../../image/icon/daohang.png" class="iconimg" alt=""> <span>项目地点：{{o.region}}</span></div>
                                <div> <img src="../../../image/icon/time.png" class="iconimg" alt=""> <span>发布时间：{{o.work_date}}</span></div>
                            </div>
                        </div>
                    </div>
                </div>
                <div class="btn-group">

                    <div v-if="o.apply_status===1" class="failure">待雇佣</div>
                    <div v-else-if="o.apply_status===2" class="failure">已雇佣</div>
                    <div v-else class="failure">已取消雇佣</div>
                    <div class="btn" v-if="o.apply_status===2 && listType===1" @click="goOrder()">去订单</div>
                    <div class="btn" v-if="o.apply_status===0" @click="del(o,i)">删除</div>
                </div>
            </div>
        </div>
    </div>
</body>
<script src="../../../script/api.js" charset="utf-8"></script>
<script src="../../../script/aui/aui-tab.js" charset="utf-8"></script>
<script src="../../../script/common/jquery-3.3.1.min.js" charset="utf-8"></script>
<script src="../../../script/common/common.js" charset="utf-8"></script>
<script src="../../../script/common/config.js" charset="utf-8"></script>
<script src="../../../script/common/vue.min.js" charset="utf-8"></script>
<script>
    apiready = function() {
        api.parseTapmode();
        vm.init();



    }

    var vm = new Vue({
        el: "#app",
        data: {
            list: [],

            listType: 1,
            listPage: 1,
            listStatus: true,
        },
        methods: {
            init() {
                this.userInfo = get_local("userInfo");
                this.upDownLoad();
                this.tabChange();
                this.getList();
            },
            getList() {
                var that = this;
                var urls = {
                    1: Config.api.UserEmployUserSpecialtyApply,
                    2: Config.api.UserEmployUserAmateurApply
                };
                var data = {
                    user_id: that.userInfo.user_id,
                    pages: that.listPage,
                };
                _ajax(urls[that.listType], data, function(ret) {
                    if (ret.code === 200) {
                        if (that.listPage === 1) {
                            that.list = ret.data;
                        } else {
                            if (ret.data.length > 0) {
                                that.list = that.list.concat(ret.data);
                            } else {
                                that.listStatus = false;
                            }
                        }
                    }
                });
            },
            del(o, index) {
                var that = this;
                var urls = {
                    1: Config.api.UserEmployRemoveUserSpecialtyApply,
                    2: Config.api.UserEmployRemoveUserAmateurApply
                };
                var data = {
                    user_id: that.userInfo.user_id,
                    apply_id: o.apply_id
                };

                _ajax(urls[that.listType], data, function(ret) {
                    if (ret.code === 200) {
                        that.list.splice(index, 1);
                        $toast("删除成功");
                    }
                });
            },
            openDemandDetails(param) {
                var demands = {
                    1: {
                        name: 'demand_details_new_win',
                        url: '../../details/demand_details_new_win.html',
                    },
                    2: {
                        name: "particulars_new_win",
                        url: "../../details/particulars_new_win.html"
                    },
                };
                open_w(demands[this.listType].name, demands[this.listType].url, param);
            },
            tabChange() {
                var that = this;
                var tab = new auiTab({
                    element: document.getElementById("tab"),
                    index: 1,
                    repeatClick: false
                }, function(ret) {
                    that.list = [];
                    that.listType = ret.index;
                    that.listPage = 1;
                    that.listStatus = true;
                    that.getList();
                });
            },
            goOrder() {
                var winInfo = {
                    name: 'get_work_win',
                    url: '../../order/get_work/get_work_win.html'
                };
                open_w(winInfo.name, winInfo.url);
            },
            upDownLoad() {
                var that = this;

                // 下拉刷新
                push_down(function() {
                    //下拉刷新恢复
                    push_down_over();
                    that.listStatus = true;
                    that.listPage = 1;
                    that.getList();
                });

                //上拉加载
                push_up(function() {
                    if (that.listStatus) {
                        that.listPage++;
                        that.getList();
                    }
                });
            }
        }
    });
</script>

</html>
